home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / file-tra / rdist-6.1 / rdist-6 / rdist-6.1.0-linuxpl2 / include / defs.h next >
Encoding:
C/C++ Source or Header  |  1995-10-16  |  11.4 KB  |  413 lines

  1. #ifndef __DEFS_H__
  2. #define __DEFS_H__
  3. /*
  4.  * Copyright (c) 1983 Regents of the University of California.
  5.  * All rights reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  * 1. Redistributions of source code must retain the above copyright
  11.  *    notice, this list of conditions and the following disclaimer.
  12.  * 2. Redistributions in binary form must reproduce the above copyright
  13.  *    notice, this list of conditions and the following disclaimer in the
  14.  *    documentation and/or other materials provided with the distribution.
  15.  * 3. All advertising materials mentioning features or use of this software
  16.  *    must display the following acknowledgement:
  17.  *    This product includes software developed by the University of
  18.  *    California, Berkeley and its contributors.
  19.  * 4. Neither the name of the University nor the names of its contributors
  20.  *    may be used to endorse or promote products derived from this software
  21.  *    without specific prior written permission.
  22.  *
  23.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  24.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  27.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  29.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  30.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  32.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  33.  * SUCH DAMAGE.
  34.  */
  35.  
  36. /*
  37.  * $Id: defs.h,v 6.77 1994/04/11 23:19:23 mcooper Exp $
  38.  * @(#)defs.h      5.2 (Berkeley) 3/20/86
  39.  */
  40.  
  41. /*
  42.  * POSIX settings
  43.  */
  44. #if    defined(_POSIX_SOURCE)
  45. #include <unistd.h>
  46. #include <stdlib.h>
  47. #endif    /* _POSIX_SOURCE */
  48. #include <stdio.h>
  49. #include <ctype.h>
  50. #include <errno.h>
  51. #include <pwd.h>
  52. #include <grp.h>
  53. #include <syslog.h>
  54. #include <setjmp.h>
  55. #include <sys/types.h>
  56. #include <sys/param.h>
  57. #include <sys/file.h>
  58. #include <sys/time.h>
  59. #include <sys/stat.h>
  60.  
  61. #include "version.h"
  62. #include "config-def.h"
  63. #include "config.h"
  64. #include "config-data.h"
  65. #include "pathnames.h"
  66. #include "types.h"
  67.  
  68. #if    !defined(yacc)
  69. #include "y.tab.h"
  70. #endif    /* yacc */
  71.  
  72. #include <signal.h>
  73.  
  74. /*
  75.  * This belongs in os-svr4.h but many SVR4 OS's
  76.  * define SVR4 externel to Rdist so we put this
  77.  * check here.
  78.  */
  79. #if    defined(SVR4)
  80. #define NEED_FCNTL_H
  81. #define NEED_UNISTD_H
  82. #define NEED_NETDB_H
  83. #endif    /* defined(SVR4) */
  84.  
  85. #if    defined(NEED_NETDB_H)
  86. #include <netdb.h>
  87. #endif    /* NEED_NETDB_H */
  88. #if    defined(NEED_FCNTL_H)
  89. #include <fcntl.h>
  90. #endif    /* NEED_FCNTL_H */
  91. #if    defined(NEED_LIMITS_H)
  92. #include <limits.h>
  93. #endif    /* NEED_LIMITS_H */
  94. #if    defined(NEED_UNISTD_H)
  95. #include <unistd.h>
  96. #endif    /* NEED_UNISTD_H */
  97. #if    defined(NEED_STRING_H)
  98. #include <string.h>
  99. #endif    /* NEED_STRING_H */
  100.  
  101. #if defined(ARG_TYPE)
  102. #if    ARG_TYPE == ARG_STDARG
  103. #include <stdarg.h>
  104. #endif
  105. #if    ARG_TYPE == ARG_VARARGS
  106. #include <varargs.h>
  107. #endif
  108. #endif    /* ARG_TYPE */
  109.  
  110.     /* boolean truth */
  111. #ifndef TRUE
  112. #define TRUE        1
  113. #endif
  114. #ifndef FALSE
  115. #define FALSE        0
  116. #endif
  117.  
  118.     /* file modes */
  119. #ifndef S_IXUSR
  120. #define S_IXUSR        0000100
  121. #endif
  122. #ifndef S_IXGRP
  123. #define S_IXGRP        0000010
  124. #endif
  125. #ifndef S_IXOTH
  126. #define S_IXOTH        0000001
  127. #endif
  128.  
  129.     /* lexical definitions */
  130. #define    QUOTECHAR    160    /* quote next character */
  131.  
  132.     /* table sizes */
  133. #define HASHSIZE    1021
  134. #define INMAX        3500
  135.  
  136.     /* expand type definitions */
  137. #define E_VARS        0x1
  138. #define E_SHELL        0x2
  139. #define E_TILDE        0x4
  140. #define E_ALL        0x7
  141.  
  142.     /* actions for lookup() */
  143. #define LOOKUP        0
  144. #define INSERT        1
  145. #define REPLACE        2
  146.  
  147.     /* Bit flag test macros */
  148. #define IS_ON(b,f)    (b > 0 && (b & f))
  149. #define IS_OFF(b,f)    !(IS_ON(b,f))
  150. #define FLAG_ON(b,f)    b |= f
  151. #define FLAG_OFF(b,f)    b &= ~(f)
  152.  
  153. /*
  154.  * POSIX systems should already have S_* defined.
  155.  */
  156. #ifndef S_ISDIR
  157. #define S_ISDIR(m)     (((m) & S_IFMT) == S_IFDIR)
  158. #endif
  159. #ifndef S_ISREG
  160. #define S_ISREG(m)     (((m) & S_IFMT) == S_IFREG)
  161. #endif
  162. #ifndef S_ISLNK
  163. #define S_ISLNK(m)     (((m) & S_IFMT) == S_IFLNK)
  164. #endif
  165.  
  166. #define ALLOC(x)     (struct x *) xmalloc(sizeof(struct x))
  167. #define A(s)        ((s) ? s : "<null>")
  168.  
  169. /*
  170.  * Environment variable names
  171.  */
  172. #define E_FILES        "FILES"            /* List of files */
  173. #define E_LOCFILE    "FILE"            /* Local Filename  */
  174. #define E_REMFILE    "REMFILE"        /* Remote Filename */
  175. #define E_BASEFILE    "BASEFILE"        /* basename of Remote File */
  176.  
  177. /*
  178.  * Suffix to use when saving files
  179.  */
  180. #ifndef SAVE_SUFFIX
  181. #define SAVE_SUFFIX    ".OLD"
  182. #endif
  183.  
  184. /*
  185.  * Get system error string
  186.  */
  187. #define SYSERR         strerror(errno)
  188.  
  189. #define COMMENT_CHAR    '#'        /* Config file comment char */
  190. #define CNULL        '\0'        /* NULL character */
  191.  
  192. /*
  193.  * These are the top level protocol commands.
  194.  */
  195. #define C_NONE        '='        /* No command - pass cleanly */
  196. #define C_ERRMSG    '\1'        /* Log an error message */
  197. #define C_FERRMSG    '\2'        /* Log a fatal error message */
  198. #define C_NOTEMSG    '\3'        /* Log a note message */
  199. #define C_LOGMSG    '\4'        /* Log a message */
  200. #define C_ACK        '\5'        /* Acknowledge */
  201. #define C_SETCONFIG    'c'        /* Set configuration parameters */
  202. #define C_DIRTARGET    'T'        /* Set target directory name */
  203. #define C_TARGET    't'        /* Set target file name */
  204. #define C_RECVREG    'R'        /* Receive a regular file */
  205. #define C_RECVDIR    'D'        /* Receive a directory */
  206. #define C_RECVSYMLINK    'K'        /* Receive a symbolic link */
  207. #define C_RECVHARDLINK    'k'        /* Receive a hard link */
  208. #define C_END        'E'        /* Indicate end of recieve/send */
  209. #define C_CLEAN        'C'        /* Clean up */
  210. #define C_QUERY        'Q'        /* Query without checking */
  211. #define C_SPECIAL    'S'        /* Execute special command */
  212. #define C_CMDSPECIAL    's'        /* Execute cmd special command */
  213. #define C_CHMOD        'M'        /* Chmod a file */
  214.  
  215. #define    ack()         (void) sendcmd(C_ACK, (char *)NULL)
  216. #define    err()         (void) sendcmd(C_ERRMSG, (char *)NULL)
  217.  
  218. /*
  219.  * Session startup commands.
  220.  */
  221. #define S_VERSION    'V'        /* Version number */
  222. #define S_REMOTEUSER    'R'        /* Remote user name */
  223. #define S_LOCALUSER    'L'        /* Local user name */
  224. #define S_END        'E'        /* End of session startup commands */
  225.  
  226. /*
  227.  * These are the commands for "set config".
  228.  */
  229. #define SC_FREESPACE    's'        /* Set min free space */
  230. #define SC_FREEFILES    'f'        /* Set min free files */
  231. #define SC_HOSTNAME    'H'        /* Set client hostname */
  232. #define SC_LOGGING    'L'        /* Set logging options */
  233.  
  234. /*
  235.  * Query commands
  236.  */
  237. #define QC_ONNFS    'F'        /* File exists & is on a NFS */
  238. #define QC_ONRO        'O'        /* File exists & is on a readonly fs */
  239. #define QC_NO        'N'        /* File does not exist */
  240. #define QC_SYM        'l'        /* File exists & is a symlink */
  241. #define QC_YES        'Y'        /* File does exist */
  242.  
  243. /*
  244.  * Clean commands
  245.  */
  246. #define CC_QUERY    'Q'        /* Query if file should be rm'ed */
  247. #define CC_END        'E'        /* End of cleaning */
  248. #define CC_YES        'Y'        /* File doesn't exist - remove */
  249. #define CC_NO        'N'        /* File does exist - don't remove */
  250.  
  251. /*
  252.  * Run Command commands
  253.  */
  254. #define RC_FILE        'F'        /* Name of a target file */
  255. #define RC_COMMAND    'C'        /* Command to run */
  256.  
  257. /*
  258.  * Name list
  259.  */
  260. struct namelist {        /* for making lists of strings */
  261.     char    *n_name;
  262.     struct    namelist *n_next;
  263. };
  264.  
  265. /*
  266.  * Sub command structure
  267.  */
  268. struct subcmd {
  269.     short    sc_type;    /* type - INSTALL,NOTIFY,EXCEPT,SPECIAL */
  270.     opt_t    sc_options;
  271.     char    *sc_name;
  272.     struct    namelist *sc_args;
  273.     struct    subcmd *sc_next;
  274. };
  275.  
  276. /*
  277.  * Cmd flags
  278.  */
  279. #define CMD_ASSIGNED    0x01    /* This entry has been assigned */
  280. #define CMD_CONNFAILED    0x02    /* Connection failed */
  281. #define CMD_NOCHKNFS    0x04    /* Disable NFS checks */
  282.  
  283. /*
  284.  * General command structure
  285.  */
  286. struct cmd {
  287.     int    c_type;        /* type - ARROW,DCOLON */
  288.     int    c_flags;    /* flags - CMD_USED,CMD_FAILED */
  289.     char    *c_name;    /* hostname or time stamp file name */
  290.     char    *c_label;    /* label for partial update */
  291.     struct    namelist *c_files;
  292.     struct    subcmd *c_cmds;
  293.     struct    cmd *c_next;
  294. };
  295.  
  296. /*
  297.  * Hard link buffer information
  298.  */
  299. struct linkbuf {
  300.     ino_t    inum;
  301.     dev_t    devnum;
  302.     int    count;
  303.     char    pathname[BUFSIZ];
  304.     char    src[BUFSIZ];
  305.     char    target[BUFSIZ];
  306.     struct    linkbuf *nextp;
  307. };
  308.  
  309. extern char           *optarg;        /* Option argument */
  310. extern char           *path_remsh;    /* Remote shell command */
  311. extern char         buf[];        /* General purpose buffer */
  312. extern char         host[];        /* Host name of master copy */
  313. extern char            *currenthost;    /* Name of current host */
  314. extern char            *progname;    /* Name of this program */
  315. extern char           **realargv;    /* Real argv */
  316. extern int        optind;        /* Option index into argv */
  317. extern int         contimedout;    /* Connection timed out */
  318. extern int         debug;        /* Debugging flag */
  319. extern opt_t         defoptions;    /* Default install options */
  320. extern int         do_fork;    /* Should we do fork()'ing */
  321. extern int         errno;        /* System error number */
  322. extern int         isserver;    /* Acting as remote server */
  323. extern int         nerrs;        /* Number of errors seen */
  324. extern int         nflag;        /* NOP flag, don't execute commands */
  325. extern opt_t         options;    /* Global options */
  326. extern int         proto_version;    /* Protocol version number */
  327. extern int         realargc;    /* Real argc */
  328. extern int        rem_r;        /* Remote file descriptor, reading */
  329. extern int         rem_w;        /* Remote file descriptor, writing */
  330. extern int         rtimeout;    /* Response time out in seconds */
  331. extern UID_T         userid;        /* User ID of rdist user */
  332. extern jmp_buf         finish_jmpbuf;    /* Setjmp buffer for finish() */
  333. extern struct group    *gr;    /* pointer to static area used by getgrent */
  334. extern struct linkbuf  *ihead;    /* list of files with more than one link */
  335. extern struct passwd   *pw;    /* pointer to static area used by getpwent */
  336. #ifdef USE_STATDB
  337. extern int         dostatdb;
  338. extern int         juststatdb;
  339. #endif /* USE_STATDB */
  340.  
  341. /*
  342.  * System function declarations
  343.  */
  344. char                    *hasmntopt();
  345. char                   *strchr();
  346. char                    *strdup();
  347. char                    *strrchr();
  348. char                    *strtok();
  349.  
  350. /*
  351.  * Our own declarations.
  352.  */
  353. char                   *exptilde();
  354. char                   *makestr();
  355. char                          *xcalloc();
  356. char                          *xmalloc();
  357. char                          *xrealloc();
  358. extern char               *basename();
  359. extern char               *getdistoptlist();
  360. extern char               *getgroupname();
  361. extern char               *getnlstr();
  362. extern char               *getnotifyfile();
  363. extern char               *getondistoptlist();
  364. extern char               *getusername();
  365. extern char               *getversion();
  366. extern char               *msgparseopts();
  367. extern char               *searchpath();
  368. extern int            any();
  369. extern int            init();
  370. extern int            install();
  371. extern int            isexec();
  372. extern int            parsedistopts();
  373. extern int            remline();
  374. extern int            setfiletime();
  375. extern int            spawn();
  376. extern struct subcmd            *makesubcmd();
  377. extern void            checkhostname();
  378. extern void            cleanup();
  379. extern void            complain();
  380. extern void            docmds();
  381. extern void            finish();
  382. extern void            log();
  383. extern void            logmsg();
  384. extern void            lostconn();
  385. extern void            markassigned();
  386. extern void            msgprusage();
  387. extern void            note();
  388. extern void            runcmdspecial();
  389. extern void            runcommand();
  390. extern void            server();
  391. extern void            setprogname();
  392. extern void            sighandler();
  393. extern void            waitup();
  394. struct namelist               *expand();
  395. struct namelist               *lookup();
  396. struct namelist               *makenl();
  397.  
  398. #if    defined(ARG_TYPE) && ARG_TYPE == ARG_STDARG
  399. extern void            debugmsg(int, char *, ...);
  400. extern void            error(char *, ...);
  401. extern void            fatalerr(char *, ...);
  402. extern void            message(int, char *, ...);
  403. extern void            setproctitle(char *fmt, ...);
  404. #else
  405. extern void            debugmsg();
  406. extern void            error();
  407. extern void            fatalerr();
  408. extern void            message();
  409. extern void            setproctitle();
  410. #endif
  411.  
  412. #endif    /* __DEFS_H__ */
  413.